{% extends 'BASE.html' %}
{% load static %}
{% block head %}
    {{ block.super }}
{% endblock head %}
{% block title %}
        公户信息展示
{% endblock title %}
{% block content %}
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <h3 class="box-title"></h3>
                    <form action="" method="get" class="navbar-form navbar-left">
                        <div class="input-group">
                            <div class="input-group-btn btn-info">
                                <select name="condition" id="search" class="btn input-group-sm btn-info"
                                        style="border: 0">
                                    <option value="" readonly>条件</option>
                                    <option value="qq_name">昵称</option>
                                    <option value="qq">QQ号</option>
                                </select>
                            </div>
                            <input type="text" name="q" class="form-control" placeholder="Search...">
                            <span class="input-group-btn">
                                <button type="submit" id="search-btn" class="btn btn-flat">
                                    <i class="fa fa-search"></i>
                                </button>
                            </span>
                        </div>
                    </form>
                    <a href="{% url 'common_add' %}" class="btn btn-primary pull-right">新增客户</a>

                </div>
                <div class="box-body">
                    <div class="row">
                        <div class="col-sm-6">
                        </div>
                    </div>
                    <form action="" method="post">
                        {% csrf_token %}
                        <div class="input-group" style="width: 220px;margin-bottom: 5px;margin-left: 15px">
                            <select name="operate" id="operate" class="form-control btn-default">
                                <option value="">选择批量操作</option>
                                <option value="batch_delete">批量删除</option>
                                <option value="batch_update">批量更改客户状态</option>
                                {% if flag %}
                                    <option value="batch_c2p">批量公转私</option>
                                {% else %}
                                    <option value="batch_c2p">批量公转私</option>
                                {% endif %}
                            </select>
                            <span class="input-group-btn">
                                <button type="submit" class="btn btn-warning btn-flat">Go!</button>
                            </span>
                        </div>
                        {% if name_str %}
                            <div class="btn text-danger" id="choose_error">顾客:{{ name_str }}已经被选走了</div>
                        {% endif %}


                        <table id="example2" class="table table-bordered table-hover text-center">
                            <thead>
                            <tr>
                                <th style="width: 6%">
                                    <span>
                                        <i class="fa fa-check-square-o"></i>
                                        <input type="checkbox" name="batch_choose">
                                    </span>
                                </th>
                                <th style="width: 5%">序号</th>
                                <th>qq</th>
                                <th>姓名</th>
                                <th>电话</th>
                                <th>来源</th>
                                <th>咨询课程</th>
                                <th>客户状态</th>
                                <th>销售老师</th>
                                <th>操作</th>

                            </tr>
                            </thead>
                            <tbody>
                            {% for customer in all_customers %}
                                <tr>
                                    <td><input type="checkbox" name="choose" value="{{ customer.pk }}"></td>
                                    <td>{{ forloop.counter }}</td>
                                    <td>{{ customer.qq }}</td>
                                    <td>{{ customer.qq_name }}</td>
                                    <td>
                                        {{ customer.phone|default:"暂无" }}
                                    </td>
                                    <td>{{ customer.get_source_display|default:'暂无' }}</td>
                                    <td>{{ customer.get_course_display|default:"暂无" }}</td>
                                    <td>{{ customer.get_status_display }}</td>
                                    <td>{{ customer.consultant.username|default:'暂无' }}</td>
                                    <td>
                                        <a style="color: #00c3cc;" href="{% url 'common_edit' customer.pk %}">
                                            <i class="fa fa-edit" aria-hidden="true"></i>
                                        </a>
                                        |
                                        <a style="color: #d9534f;" href="{% url 'common_del' customer.pk %}">
                                            <i class="fa fa-trash-o"></i>
                                        </a>
                                    </td>
                                </tr>
                            {% endfor %}

                            </tbody>
                            <tfoot>
                            </tfoot>
                        </table>
                        {% if not all_customers %}
                            <h3 class="text-center">没有相关记录！</h3>
                        {% endif %}
                    </form>


                    <div class="pull-right" style="display:inline-block; width: 120px;margin: 22px 10px">
                        {{ jump_tag|safe }}
                    </div>

                    <div class="pull-right">
                        {{ paginator_tag|safe }}
                    </div>


                </div>
                <!-- /.box-body -->
            </div>
            <!-- /.box -->
        </div>
        <!-- /.col -->
    </div>
{% endblock content %}
{% block js %}
    {{ block.super }}
{% endblock js %}

{% block customjs %}
    <script>
        $("[name=batch_choose]").click(function () {
            var status = $(this).prop("checked");
            $("[name=choose]").prop('checked', status)
        });
        $("#choose_error").click(function () {
            $("#choose_error").css("display", "none");
        })
    </script>
    {{ jump_js|safe }}
{% endblock customjs %}